home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / EXPORT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-07  |  1.6 KB  |  70 lines

  1. /* PBBS Export file client
  2.  * Copyright 1995 Brian A. Lantz, KO4KS
  3.  */
  4. #include "global.h"
  5. #ifdef BBSEXPORT
  6. #include "commands.h"
  7. #include "mbuf.h"
  8. #include "socket.h"
  9. #include "session.h"
  10. #include "netuser.h"
  11. #include "mailbox.h"
  12. #include "files.h"
  13. #include "smtp.h"
  14.  
  15.  
  16. #if !defined(_lint)
  17. static char rcsid[] OPTIONAL = "$Id: export.c,v 1.12 1997/09/07 21:18:28 root Exp root $";
  18. #endif
  19.  
  20. static void exporttick (void *p);
  21.  
  22. static struct timer exporttimer;
  23. #define MSPMINUTE (1000L*60L)
  24.  
  25.  
  26. int
  27. doexport(argc,argv,p)
  28. int argc;
  29. char *argv[];
  30. void *p OPTIONAL;
  31. {
  32.     if(argc < 2){
  33.         tprintf("export timer: %lu/%lu minutes\n",
  34.             read_timer(&exporttimer)/MSPMINUTE,
  35.             dur_timer(&exporttimer)/MSPMINUTE);
  36.         return 0;
  37.     }
  38.     if(*argv[1] == 'n') {
  39.         exporttick(NULL);
  40.         return 0;
  41.     }
  42.     stop_timer (&exporttimer);    /* just in case */
  43.     exporttimer.func = (void (*)(void *))exporttick;/* what to call on timeout */
  44.     exporttimer.arg = NULL;        /* dummy value */
  45.     set_timer(&exporttimer,atol(argv[1])*MSPMINUTE); /* set timer duration */
  46.     start_detached_timer(&exporttimer);     /* fire it up */
  47.     return 0;
  48. }
  49.  
  50. static void
  51. exporttick(p)
  52. void *p OPTIONAL;
  53. {
  54. char tempname[512], tempname2[512];
  55. time_t t;
  56. struct tm *tp;
  57.  
  58.     sprintf (tempname, "%s/export.exp", EXPORTDir);
  59.     if (!access (tempname, 0))    {
  60.         t = time ((time_t *)0);
  61.         tp = localtime (&t);
  62.         sprintf (tempname2, "%s/%02d%02d%02d%02d.exp", EXPORTDir,
  63.             tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min);
  64.         (void) rename (tempname, tempname2);
  65.     }
  66.     start_detached_timer(&exporttimer);
  67. }
  68.  
  69. #endif /* BBSEXPORT */
  70.